#!/bin/bash

source src/conf/config.conf
touch pxelinux.cfg/centos.cfg
cd $tftp_dir

mirror=http://mirrors.nfsi.pt/CentOS/$centos_ver/os/$centos_arch/images/

echo " Downloading CentOS..."

 for ARCH in i386 x86_64; do
wget -q -c  $mirror/pxeboot/initrd.img && mv initrd.img "LINUX/centos/${ARCH}/"

wget -q -c $mirror/pxeboot/vmlinuz && mv vmlinuz "LINUX/centos/${ARCH}/"

wget -q -c $mirror/install.img && mv install.img "LINUX/centos/${ARCH}/"



#wget -c  http://mirrors.nfsi.pt/CentOS/$centos_ver/os/$centos_arch/images/pxeboot/initrd.img && mv initrd.img "LINUX/centos/${ARCH}/"
#wget -c http://mirrors.nfsi.pt/CentOS/$centos_ver/os/$centos_arch/images/pxeboot/vmlinuz && mv vmlinuz "LINUX/centos/${ARCH}/"
#wget -c http://mirrors.nfsi.pt/CentOS/$centos_ver/os/$centos_arch/images/install.img && mv install.img "LINUX/centos/${ARCH}/"

done

cat >> pxelinux.cfg/linux << EOF

DEFAULT install
PROMPT 1
TIMEOUT 50 
menu title CentOS Installer
menu include pxelinux.cfg/graphics.conf
MENU BACKGROUND pxelinux.cfg/background.png


MENU BEGIN oses-submenu
 LABEL Previous
        MENU LABEL Previous Menu
        TEXT HELP
        Return to previous menu
        ENDTEXT
        MENU EXIT
 MENU TITLE Install CentOS
MENU INCLUDE pxelinux.cfg/centos.cfg

MENU END


EOF

    for ARCH in i386 x86_64; do
        echo "label Install centos ${ARCH}"
        echo "      menu label centos ${ARCH}"
        echo "      kernel LINUX/centos/${ARCH}/vmlinuz"
        echo "      append initrd= LINUX/centos/${ARCH}/initrd.img ks=http://pxe.sytes.net/answerfiles/kickstart/centos-ks.cfg askmethod"
      echo " "
	echo " TEXT HELP"
       echo "  Install centos ${ARCH}"
        echo " ENDTEXT"

done >> pxelinux.cfg/centos.cfg


